<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
	<head>
		<meta charset="UTF-8">
		<script type="text/javascript" class="autoinsert" src="js/jquery-2.2.0.min.js"></script>
		<!-- bootstrap规定使用前置设置 -->
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link href="bootstrap-3.3.7-dist/css/bootstrap.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="bootstrap-3.3.7-dist/js/bootstrap.js"></script>
		<link rel="stylesheet" href="font-awesome-4.7.0/css/font-awesome.min.css">
		<link rel="stylesheet" type="text/css" href="css/houtai_addmy_hotel.css" />
		<script type="text/javascript" class="autoinsert" src="js/layer.js"></script>
		<link rel="stylesheet" type="text/css" href="css/layer.css" />
		<script type="text/javascript" src="js/houtai_addmy_hotel.js"></script>
		<title>添加旅店</title>
	</head>
	<body>

		<%@ include file="houtai_left.jsp"%>
		<%@ include file="houtai_top.jsp"%>

		<input type="hidden" id="show_left" value="${show_left}" />
		<script type="text/javascript">
			$("div[id*='left_y']").hide();
			var now_left = $("#now_left").val();
			$("#" + now_left).show();
			var show_left = $("#show_left").val();
			$("#" + show_left).attr("style", "background: #293038;");
		</script>

		<div class="main">

			<div class="main_top">
				<h5 class="main_top_text">添加旅店</h5>
			</div>
			
			<div class="main_show">
				<div class="main_show_name">
					<div class="main_show_text">请输入路线id：</div>
					<input type="text" id="tid" name="tid" value="" />
				</div>
				<div class="main_show_name">
					<div class="main_show_text">请输入旅店名：</div>
					<input type="text" id="name" name="name" value="" />
				</div>
				
				<button class="main_show_button" onclick="to_add()"><a href="#" class="main_show_a">确认添加<i class="fa fa-check-square-o" style="padding-left: 5px;"></i></a></button>
				
				<script type="text/javascript">
					function to_add() {
						if ( $("#tid").val() != "" && $("#name").val() != "" ) {
							$.ajax({
								type: "POST",
								url: "${pageContext.request.contextPath}/addmy_hotel",
								data: {
									tid: $("#tid").val(),
									name: $("#name").val()
								},
								dataType: "json",
								success: function(result) {
									if (result.code == "1") {
										location.href = "${pageContext.request.contextPath}/my_hotel";
									}else {
										layer.msg('系统错误，请退出后重试!', {
											time: 1500
										});
									}
								},
								error: function() {
									//alert("請求失敗");
								}
							});
						} else {
							layer.msg('请将信息完整输入!', {
								time: 2000
							});
						}
					}
				</script>

			</div>

		</div>

	</body>
</html>
